-
-
Notifications
You must be signed in to change notification settings - Fork 449
Add a new text command for a more ergonomic way to attach text to the chat interface #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@joadoumie Thank you for contributing this! I just got back from some software conferences, so I appreciate your patience until I'm able to review this. BTW, we have recently added a feature where users can drag & drop selections into the chat input. That might solve the original issue for this PR, but I'm also open to having these 2 features live together in parallel. Have to test this locally to arrive at a recommendation. |
I think drag and drop is a great feature, and probably solves for a different user flow (folks who prefer interactivity with the keyboard and keyboard shortcuts). I'd probably use both, but it'd be interesting to try them out together. |
I think it would be helpful to be able to attach using keyboard shortcuts, but we should use the new attachment system for the content. This is a more flexible and powerful way of attaching context from different documents to the chat that gives agents/personas for control over what appears in the context/chat history and has a more streamlined UX. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing this! This is a great addition to Jupyter AI & provides a keyboard-only option for adding a selection as context. There are 2 potential improvements that I'd like you to explore before merging:
- The added context should be attached as an attachment instead of being injected directly into the prompt. This can be done via
inputModel.addAttachment()
. A reference for this can be found inside of the@file
command provider. The attachments API should now support selection ranges.
- Thanks to your previous contribution in #1419, this attachment will be read by Jupyternaut. Right now I believe it will read the whole file. There's no need to implement reading only selection ranges in this PR since we will add an agent tool for this (read further).
- A user generally only has one selection at any given time, so I recommend just providing a single
@selection
command instead of two@text
commands. If a text selection is available, use that, otherwise use the cell selection.
I totally understand any reservation about using the attachments API. It is more complex and the UX can be improved, but there is a good motivation for this. By v3.0.0 official, Jupyternaut will be made agentic & be provided tools to read files on their own. I have a local branch of this working and will open a PR for this next week.
By having the AI agent load the content itself, we can reduce the time-to-first-response by having a smaller initial prompt, and most importantly, make AI reads/writes to the filesystem traceable for server operators & admins.
(congrats on getting feedback from the co-founder of Project Jupyter BTW! that's Brian.)
@dlqqq -- I made some changes given your feedback. I don't think the attachment API quite fits the desired UX just yet, but I think this is directionally correct. I also took a look at #1479 to try to better understand how this flow may fit in with a world of agentic tool calling (which I'm really excited about). I am going to temporarily move this PR into draft status so I can revisit it after better understanding some of the possibilities/limitations with the tools based approach. |
Description
This PR introduces a new TextCommandProvider that allows users to include text content directly into chat messages via
@text:
commands. This allows users to quickly include active cell content or selected text in their chat messages, providing an alternative to the dropdown menu interface. This is a more ergonomic method of attaching commands for folks that use keyboard over mouse.Code changes
New File
packages/jupyter-ai/src/chat-command-plugins/text-command.tsx
TextCommandProvider
class, following the same pattern asFileCommandProvider
.@text:active_cell
– inserts the content of the currently active notebook cell.@text:selected_text
– inserts any text currently selected in the editor.act
only shows theactive_cell
option).Modified
packages/jupyter-ai/src/chat-command-plugins/index.ts
textCommandPlugin
to the exported plugins array.User-facing changes
Users can now type
@text:
in the chat input to trigger autocomplete suggestions:@text:active_cell
→ Includes the content of the currently active notebook cell.@text:selected_text
→ Includes any text currently selected in the editor.Backwards-incompatible changes
None that I know of.